package com.example.writting.ui.wordfill

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.writting.data.WordFillDataSource
import com.example.writting.databinding.FragmentSupplementsBinding
import com.example.writting.ui.wordfill.adapters.SupplementAdapter

class SupplementsFragment : Fragment() {

    private var _binding: FragmentSupplementsBinding? = null
    private val binding get() = _binding!!
    private val adapter = SupplementAdapter()

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        _binding = FragmentSupplementsBinding.inflate(inflater, container, false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        setupRecyclerView()
        loadData()
    }

    private fun setupRecyclerView() {
        binding.recyclerView.layoutManager = LinearLayoutManager(context)
        binding.recyclerView.adapter = adapter
    }

    private fun loadData() {
        adapter.updateItems(WordFillDataSource.supplements)
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }
} 